import com.demo.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class GetBeanExample {
    public static void main(String[] args) {
        //1.得到容器对象
        ApplicationContext context=new ClassPathXmlApplicationContext("spring-config.xml");
        //2.获取Bean
        //注意：当同一个类型注入到spring多个时，该方法会报错
//        UserService userService=context.getBean(UserService.class);
//        //3.使用Bean
//        userService.sayHi();
    }
}
